+Thu Dec 22 16:01:27 2005 Tim Janik <timj@imendio.com>
+
+ * gtk/gtkobject.c: derive GtkObject from GUnowned,
+ so it initially has a floating reference count.
+ gtk_object_class_init(): installa floating flag handler with
+ libgobject, so for GtkObjects the flag is stored as GTK_FLOATING
+ in the ->flags member.
+
+ * tests/floatingtest.c: test floating flag uses.
+
2005-12-21 Matthias Clasen <mclasen@redhat.com>
* gdk/gdkregion-generic.c: Use the slice allocator
+Thu Dec 22 16:01:27 2005 Tim Janik <timj@imendio.com>
+
+ * gtk/gtkobject.c: derive GtkObject from GUnowned,
+ so it initially has a floating reference count.
+ gtk_object_class_init(): installa floating flag handler with
+ libgobject, so for GtkObjects the flag is stored as GTK_FLOATING
+ in the ->flags member.
+
+ * tests/floatingtest.c: test floating flag uses.
+
2005-12-21 Matthias Clasen <mclasen@redhat.com>
* gdk/gdkregion-generic.c: Use the slice allocator
NULL, /* value_table */
};
- object_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkObject"),
+ object_type = g_type_register_static (G_TYPE_UNOWNED, I_("GtkObject"),
&object_info, G_TYPE_FLAG_ABSTRACT);
}
g_object_class_install_property (oclass, arg_id, pspec);
}
+static guint
+gtk_object_floating_flag_handler (GtkObject *object,
+ gint job)
+{
+ /* FIXME: remove this whole thing once GTK+ breaks ABI */
+ switch (job)
+ {
+ guint32 oldvalue;
+ case +1: /* force floating if possible */
+ do
+ oldvalue = g_atomic_int_get (&object->flags);
+ while (!g_atomic_int_compare_and_exchange (&object->flags, oldvalue, oldvalue | GTK_FLOATING));
+ return oldvalue & GTK_FLOATING;
+ case -1: /* sink if possible */
+ do
+ oldvalue = g_atomic_int_get (&object->flags);
+ while (!g_atomic_int_compare_and_exchange (&object->flags, oldvalue, oldvalue & ~(guint32) GTK_FLOATING));
+ return oldvalue & GTK_FLOATING;
+ default: /* check floating */
+ return 0 != (g_atomic_int_get (&object->flags) & GTK_FLOATING);
+ }
+}
+
static void
gtk_object_class_init (GtkObjectClass *class)
{
parent_class = g_type_class_ref (G_TYPE_OBJECT);
+ g_object_compat_control (2, gtk_object_floating_flag_handler);
+
gobject_class->set_property = gtk_object_set_property;
gobject_class->get_property = gtk_object_get_property;
gobject_class->dispose = gtk_object_dispose;
typedef enum
{
GTK_IN_DESTRUCTION = 1 << 0, /* Used internally during dispose */
-#ifndef GTK_DISABLE_DEPRECATED
+#if !defined (GTK_DISABLE_DEPRECATED) || defined (GTK_COMPILATION)
GTK_FLOATING = 1 << 1,
#endif
GTK_RESERVED_1 = 1 << 2,
testsocket_programs = testsocket testsocket_child
endif
+TESTS = floatingtest
noinst_PROGRAMS = \
autotestfilechooser \
+ floatingtest \
simple \
testaccel \
testcairo \
autotestfilechooser_DEPENDENCIES = $(TEST_DEPS)
simple_DEPENDENCIES = $(TEST_DEPS)
+floatingtest_DEPENDENCIES = $(TEST_DEPS)
testicontheme_DEPENDENCIES = $(TEST_DEPS)
testiconview_DEPENDENCIES = $(TEST_DEPS)
testaccel_DEPENDENCIES = $(TEST_DEPS)
testactions_DEPENDENCIES = $(TEST_DEPS)
autotestfilechooser_LDADD = $(LDADDS)
-simple_LDADD = $(LDADDS)
+floatingtest_LDADD = $(LDADDS)
testaccel_LDADD = $(LDADDS)
testcairo_LDADD = $(LDADDS)
testcalendar_LDADD = $(LDADDS)
--- /dev/null
+/* floatingtest.c - test floating flag uses
+ * Copyright (C) 2005 Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#undef GTK_DISABLE_DEPRECATED
+#include "../gtk/gtk.h"
+
+static gboolean destroyed = FALSE;
+static void destroy (void) { destroyed = TRUE; }
+
+int
+main (int argc,
+ char *argv[])
+{
+ GtkWidget *widget;
+ gtk_init (&argc, &argv);
+
+ widget = g_object_new (GTK_TYPE_LABEL, NULL);
+ g_object_connect (widget, "signal::destroy", destroy, NULL, NULL);
+
+ g_assert (GTK_OBJECT_FLOATING (widget));
+ g_assert (g_object_is_floating (widget));
+
+ GTK_OBJECT_UNSET_FLAGS (widget, GTK_FLOATING);
+ g_assert (!GTK_OBJECT_FLOATING (widget));
+ g_assert (!g_object_is_floating (widget));
+
+ GTK_OBJECT_SET_FLAGS (widget, GTK_FLOATING);
+ g_assert (GTK_OBJECT_FLOATING (widget));
+ g_assert (g_object_is_floating (widget));
+
+ g_object_ref_sink (widget);
+ g_assert (!GTK_OBJECT_FLOATING (widget));
+ g_assert (!g_object_is_floating (widget));
+
+ g_object_force_floating (G_OBJECT (widget));
+ g_assert (GTK_OBJECT_FLOATING (widget));
+ g_assert (g_object_is_floating (widget));
+
+ g_object_ref (widget);
+ gtk_object_sink (GTK_OBJECT (widget));
+ g_assert (!GTK_OBJECT_FLOATING (widget));
+ g_assert (!g_object_is_floating (widget));
+
+ g_assert (!destroyed);
+ g_object_unref (widget);
+ g_assert (destroyed);
+
+ return 0;
+}